package de.rj.urwalking.ui;

import android.content.Context;
import android.view.MotionEvent;
import android.widget.FrameLayout;
import de.rj.urwalking.ui.activities.URwalkingActivity;

/**
 * http://dimitar.me/how-to-detect-a-user-pantouchdrag-on-android-map-v2/
 * 
 * 
 */

public class TouchableWrapper extends FrameLayout {

	private URwalkingActivity mActivity;

	public TouchableWrapper(Context context) {
		super(context);
		// Force the host activity to implement the URwalkingFragment.Callback
		// Interface
		try {
			mActivity = (URwalkingActivity) context;
		} catch (ClassCastException e) {
			throw new ClassCastException("TouchableWrapper can only be used inside URwalkingActivity");
		}
	}

	@Override
	public boolean dispatchTouchEvent(MotionEvent ev) {
		switch (ev.getAction()) {
		case MotionEvent.ACTION_DOWN:
			mActivity.disableGpsFollowing(false);
			mActivity.disableCompassMovement(false);
			break;
		case MotionEvent.ACTION_UP:

			break;
		}
		return super.dispatchTouchEvent(ev);
	}

}
